package assdraw2.coloragent;

import assdraw2.coloragent.presentation.ColorPresentation;
import assdraw2.common.MessageType;
import assdraw2.common.PACAgent;
import assdraw2.common.PACMessage;

public class ColorControl implements PACAgent{

	private PACAgent parent;
	private ColorPresentation presentation;

	public ColorControl(PACAgent parent) {
		this.parent = parent;
	}


	@Override
	public void receiveMessage(PACMessage m) {
		if(m.getType() == MessageType.OPEN){ 				
			presentation = new ColorPresentation(this);
		}else if(m.getType() == MessageType.CLOSE){
			presentation.dispose();
		}
		
	}

	@Override
	public void sendMessage(PACMessage m) {
			parent.receiveMessage(m);
		
	}
	
	public PACAgent getParentAgent() {
		return parent;
	}
}
